var cache={},search=!0;function obterSuggest(e,t,n){$(t).autocomplete({minLength:2,autoFocus:!0,open:function(e,n){$(".ui-autocomplete").css("z-index","9999999").outerWidth($(t).outerWidth())},change:function(e,a){$(t).on("keyup",(function(e){"Backspace"!==e.key&&"Del"!==e.key||$(n).val("")})),null==a.item&&$(n).val(""),$(".popover").remove(),e.preventDefault()},source:async function(t,n){let a=t.term,{originURL:r,nameOfParam:i}=urlOriginSugget(e),u=$(this.element).data("jqXHR");if(a in cache)return void n(cache[a]);u&&u.abort();let o=await ajaxRequest(`${GLOBAL_API_URL}${r}${a}&LimitSuggestion=50`,"GET",null,!0),c=[];o.data.forEach((e=>c.push({id:e.id,value:e[i]}))),n(c.sort())},select:function(e,a){$(n).val(a.item.id);var r=$(t).closest("form");r.length>=1&&r.validate().element($(this))}}).focus((function(){""!=this.value&&$(this).autocomplete("search")}))}function urlOriginSugget(e){switch(e){case"cidade":return{originURL:"/City/Suggest?CityName=",nameOfParam:"formatedName"};case"somenteCidade":return{originURL:"/City/Suggest?CityName=",nameOfParam:"name"};case"funcao":return{originURL:"/JobTitle/Suggest?JobTitle=",nameOfParam:"name"};case"instituicaoEnsino":return{originURL:"/Institution/Suggest?institution=",nameOfParam:"name"};case"curso":return{originURL:"/Course/Suggest?course=",nameOfParam:"name"}}}function ajaxRequest(e,t,n=null,a=!1){return new Promise(((r,i)=>{$.ajax({type:t,url:e,data:JSON.stringify(n),contentType:"application/json; charset=utf-8",dataType:"json",async:a,success:function(e){return r(e)},error:function(e){return i(e)}})}))}function ajaxRequestReturnHtml(e,t){return new Promise(((n,a)=>{$.ajax({type:t,url:e,dataType:"html",cache:!1,async:!1,success:function(e){return n(e)},error:function(e){return a(e)}})}))}function ajaxRequestFile(e,t,n=null){return new Promise(((a,r)=>{$.ajax({type:t,url:e,data:n,processData:!1,contentType:!1,async:!1,success:function(e){return a(e)},error:function(e){return r(e)}})}))}